#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"
#include <math.h>
#include <stdlib.h>
#include <stdio.h>

#define DEBUG 0
#define NOISY_TEST 1

  int check_outpost(int card, int choice1, int choice2, int choice3, struct gameState *post, int handPos, int bonus) {
  struct gameState pre;
  memcpy (&pre, post, sizeof(struct gameState));
  int r;
  r = cardEffect(card, choice1, choice2, choice3, post, handPos, &bonus);
  pre.outpostPlayed++;
  discardCard(handPos, pre.whoseTurn, &pre, 0);
  assert (r == 0);

  assert(memcmp(&pre, post, sizeof(struct gameState)) == 0);
  return 0;
}

int main () {

  int i, n, p, r, bonus, handPos;
  
  int k[10] = {adventurer, council_room, feast, gardens, mine,
	       remodel, smithy, village, baron, great_hall};
  int card = outpost;
  struct gameState G;
  printf ("Testing outpost.\n");

  printf ("RANDOM TESTS.\n");

  SelectStream(2);
  PutSeed(3);
  handPos = 2;
  for (n = 0; n < 2000; n++) {
    initializeGame(2, k, 2, &G);
    p = floor(Random() * 2);
    bonus = floor(Random() * 10);
    G.coins = floor(Random() * 20);
    check_outpost(card, 1, -1, -1, &G, handPos, bonus); 
  }


/*
  printf ("SIMPLE FIXED TESTS.\n");
  for (p = 0; p < 2; p++) {
     for (coins = 0; coins < 15; coins++) {
        for (bonus = 0; bonus < 15; bonus++) {
	  memset(&G, 23, sizeof(struct gameState)); 
	  r = initializeGame(2, k, 1, &G);
	  G.coins = coins;
	  checkupdateCoins(p, &G, bonus);
	}
      }
    }
  */
  printf ("ALL TESTS OK\n");

  return 0;
}
